//
//  OrderViewModel.m
//  Futures
//
//  Created by Cheng on 2017/7/12.
//  Copyright © 2017年 Cheng. All rights reserved.
//

#import "OrderViewModel.h"

@implementation OrderViewModel
//传参：account,symbol,buysell=@"买入",@"卖出",price=0市价单,qty=1（手数）,ordertype目前只支持市价单
+ (void)requestSendOrderBuysell:(NSString *)buysell qty:(int)qty block:(void (^)(id obj))block{
    NSString *cid = GLOBAL_INSTANCE.user.cid;
    NSString *symbol = GLOBAL_INSTANCE.quoteModel.Symbol;
    NSAssert(cid !=nil, @"cid is null");
    NSAssert(symbol != nil, @"cid is null");
    NSDictionary *dict = @{@"account":cid,
                           @"symbol":symbol,
                           @"buysell":buysell,
                           @"price":@0,
                           @"qty":@(qty),
                           @"ordertype":@"市价"};
    [Network requestDataMethod:GET WithUrl:URL_SEND_ORDER parameters:dict success:^(NSURLSessionDataTask *task, id responseObject) {
        MYLog(@"%@",responseObject);
        block(@"Success!");
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}

+ (void)requestSendOrderSymbol:(NSString *)symbol Buysell:(NSString *)buysell qty:(int)qty block:(void (^)(id obj))block{
    NSString *cid = GLOBAL_INSTANCE.user.cid;
    NSAssert(cid !=nil, @"cid is null");
    NSAssert(symbol != nil, @"cid is null");
    NSDictionary *dict = @{@"account":cid,
                           @"symbol":symbol,
                           @"buysell":buysell,
                           @"price":@0,
                           @"qty":@(qty),
                           @"ordertype":@"市价"};
    [Network requestDataMethod:GET WithUrl:URL_SEND_ORDER parameters:dict success:^(NSURLSessionDataTask *task, id responseObject) {
        MYLog(@"%@",responseObject);
        NSString *result = responseObject[@"Message"];
        block(result);
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}


@end
